module.exports = app => {
var express = require('express')
var router = express.Router()
var customer = require('../../models/customer')
//给超级用户添加邀请码的功能
router.put('/addInvite', async(req, res) => {
    const {token,inviteKey} = req.body
    await customer.updateOne({ token: token},{$set :{inviteKey}},(err)=>{
        err ? res.send('服务器错误...') : res.send('ok')
    })
})

router.get('/getAllInvites', async(req, res) => {
    const data = await customer.find({status:0})
    res.send(data);
})

router.get('/getInvite', async(req, res) => {
    const token = req.query.token
    const data = await customer.find({token})
    res.send(data);
})
app.use('/api',router)

}
